SELECT DATEPART(weekday, CAST( '2021-12-31' as DATE));
GO

SELECT @@DATEFIRST;
GO

SET DATEFIRST 1
GO

SELECT @@DATEFIRST;
GO

SELECT DATEPART(weekday, CAST( '2021-12-31' as DATE));
GO


DECLARE @rc INT = 3;
SET DATEFIRST @rc;
GO

SELECT @@DATEFIRST;
GO

SELECT DATEPART(weekday, CAST( '2021-12-31' as DATE));
GO

-- reset it to 7
SET DATEFIRST 7
GO

SELECT @@DATEFIRST;
GO

SELECT DATEPART(weekday, CAST( '2021-12-31' as DATE));
GO

-- invalid settings
SET DATEFIRST 0
GO

SET DATEFIRST 8
GO

SET DATEFIRST NULL;
go

DECLARE @rc INT = 0;
SET DATEFIRST @rc;
GO

DECLARE @rc INT = 8;
SET DATEFIRST @rc;
GO


DECLARE @rc INT = NULL;
SET DATEFIRST @rc;
GO

SELECT @@DATEFIRST;
GO

